<?php

/**
 * 头像输出
 */

namespace app\member\common;

class AvatarCommon {

    protected function index() {
        $id = request('get', 'id', 0, 'intval');
        $type = request('get', 'type', 0, 'intval');
        if (empty($id)) {
            return;
        }

        switch ($type) {
            case 1:
                $type = 32;
                break;
            case 3:
                $type = 128;
                break;
            case 2:
            default:
                $type = 64;
                break;

        }
        $avatar = ROOT_PATH . 'upload/avatar/' . $id . '/'. $type . '.jpg';
        if(!is_file($avatar)) {
            $avatar = ROOT_PATH . 'public/member/images/avatar.jpg';
        }

        header('content-type: image/png');
        echo file_get_contents($avatar);
    }

}